import axios from 'axios'
import { MessageBox, Message } from 'element-ui'

// create an axios instance
const service = axios.create({
    //基础的根路径
    baseURL: "http://localhost:8888", 
    //超时时间
  timeout: 5000 
})

// 响应的拦截器
service.interceptors.response.use(
  response => {
    const res = response.data
        //这里是成功,则返回内容
      return res
  },
  error => {
    console.log("------------");
    console.log('err' + error) // for debug
    Message({
      message: error.message,
      type: 'error',
      duration: 2 * 1000
    })
    return Promise.reject(error)
  }
)

export default service
